package ChrisC;

import org.uispec4j.Button;
import org.uispec4j.Table;
import org.uispec4j.UISpecTestCase;
import org.uispec4j.Window;


public class CreateContactTest extends UISpecTestCase {
	
	public void testCreatingAContact() throws Exception {
		  // 1. Retrieve the components
		  Window window = getMainWindow();
		  Table table = window.getTable();
		  Button newContactButton = window.getButton("New contact");
		  

		  // 2. Check that the contacts table is empty and displays
		  // the proper column names
		  assertTrue(table.getHeader().contentEquals(new String[]{
		    "User Name", "Password", "Confirm Pass", "Email"
		  }));
		  assertTrue(table.isEmpty());

		  // 3. Click on the "New contact" button and check that an
		  // empty row is displayed in the contacts table
		  newContactButton.click();
		  assertTrue(table.contentEquals(new String[][]{
		    {"", "", "", ""}
		  }));
		  assertTrue(table.rowIsSelected(0));

		  // 4. Change the fields of the created empty contact and check
		  // that the contacts table is updated accordingly
		  window.getTextBox("username").setText("TestUser");
		  window.getTextBox("pass").setText("12345");
		  window.getTextBox("confPass").setText("12345");
		  window.getTextBox("email").setText("user@test.com");
		  assertTrue(table.contentEquals(new String[][]{
		    {"TestUser", "12345", "12345", "user@test.com"}
		    
		    
		    
		    
		  }));
		  
		  window.getTextBox("pass").setText("12345");
		  window.getTextBox("confPass").setText("45678");
		  assertTrue(table.contentEquals(new String[][]{
				    {"12345", "12345"}
		  }));
		}
	

}
